//
//  MessageCtrl.swift
//  SwfitBase
//
//  Created by rubick on 2023/1/17.
//

import UIKit

class MessageCtrl: RKBaseCtrl {
    var subPages: [String]!
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "信息"
        subPages = ["秒表", "瀑布流", "粒子动画", "Gif图", "ActivityIndicator"]
        setupChildren()
    }
    func setupChildren() {
        let tableView = UITableView(frame: self.view.frame, style: .plain)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.tableFooterView = UIView()
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCellIdentifier")
        self.view.addSubview(tableView)
    }
}
extension MessageCtrl: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.subPages.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCellIdentifier")!
        cell.accessoryType = .disclosureIndicator
        cell.textLabel?.text = self.subPages[indexPath.row]
        return cell
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        if indexPath.row == 0 {
            let temp = StopWatchCtrl()
            self.navigationController?.pushViewController(temp, animated: true)
        } else if indexPath.row == 1 {
            let temp = WaterfallCtrl()
            self.navigationController?.pushViewController(temp, animated: true)
        } else if indexPath.row == 2 {
            let temp = EmitterPage()
            self.navigationController?.pushViewController(temp, animated: true)
        } else if indexPath.row == 3 {
            let temp = PlayGitVC()
            self.navigationController?.pushViewController(temp, animated: true)
        } else if indexPath.row == 4 {
            //
        }
    }
}
